cd "`dirname $0`"
filefolder=`date +%Y%m`
nowdate=`date '+%Y-%m-%d %H:%M:%S'`
filename=`date +%d%H%M%S`
day=`date +%d`

echo "$nowdate 开始获取外网Ip"
mkdir -p $filefolder

rm -rf $filefolder/$day*.txt

git commit -a -m "delete $day*.txt"

filename=`date +%d%H%M%S`
curl -o $filefolder/$filename.txt -# -G http://1212.ip138.com/ic.asp
curl -o ip.txt -# -G http://members.3322.org/dyndns/getip

ip=`sed -n '1p' ip.txt`
echo "$nowdate 当前外网Ip为$ip" > README.md

/usr/local/git/bin/git add $filefolder/$filename.txt
/usr/local/git/bin/git commit -a -m "当前外网Ip为$ip"
/usr/local/git/bin/git push origin master --force
